package com.firmboy.springboot_axis2.config;

import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.AxisServlet;
import org.apache.axis2.util.OnDemandLogger;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;

/**
 * @author firmboy
 * @create 2018-06-08 下午7:32
 **/
public class AxisServletExport extends AxisServlet {

    static final OnDemandLogger log = new OnDemandLogger(AxisServletExport.class);

    /**
     * Initialize the Axis configuration context
     *
     * @param config Servlet configuration
     * @return ConfigurationContext
     * @throws ServletException
     */
    @Override
    protected ConfigurationContext initConfigContext(ServletConfig config) throws ServletException {
        try {
            ConfigurationContext configContext =
                    ConfigurationContextFactory
                            .createConfigurationContext(new WarBasedAxisConfiguratorExport(config));
            configContext.setProperty(Constants.CONTAINER_MANAGED, Constants.VALUE_TRUE);
            return configContext;
        } catch (Exception e) {
            log.info(e);
            throw new ServletException(e);
        }
    }

}
